/**
 * Created by chang on 2017/5/3.
 */
import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'
import config from '../../config/index'
import localStorage from '../assets/utils/localStorage'
Vue.use(Vuex)

import menus from '../servers/Menus'
import login from '../servers/Login'

export default new Vuex.Store({
  modules: {
    menus,
    login
  },
  // 状态持久化插件
  plugins: [createPersistedState({
    key: config.build.assetsPublicPath + 'vuex',
    paths: ['menus', 'login'], // 只缓存service里面的state
    getState: (key) => localStorage.get(key),
    setState: (key, state) => localStorage.set(key, state)
  })]
})
